// API Response Types
export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  message?: string;
  pagination?: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
}

// Token Types
export interface Token {
  id: string;
  mint: string;
  name: string;
  symbol: string;
  decimals: number;
  supply: string;
  description?: string;
  image?: string;
  creator: string;
  marketCap: number;
  price: number;
  holders: number;
  isActive: boolean;
  
  // 链类型标识
  chain?: 'solana' | 'xlayer' | 'bsc';
  
  // 联合曲线状态
  isBondingCurve?: boolean;
  isGraduated?: boolean;
  
  // 靓号地址信息
  isPrettyAddress?: boolean;
  prettyPrefix?: string;
  prettySuffix?: string;
  prettyConfig?: any;
  
  // 社交链接
  website?: string;
  twitter?: string;
  telegram?: string;
  discord?: string;
  
  // 权限状态
  updateAuthority?: string;
  freezeAuthority?: string;
  mintAuthority?: string;
  isUpdateRevoked?: boolean;
  isFreezeRevoked?: boolean;
  isMintRevoked?: boolean;
  
  metadata?: any;
  createdAt: string;
  updatedAt: string;
  transactions?: Transaction[];
  priceHistory?: PriceHistory[];
}

export interface CreateTokenDto {
  // 基本信息
  name: string;
  symbol: string;
  decimals?: number;
  supply?: string;
  description?: string;
  image?: string;
  creator: string;

  // 支付信息
  paymentSignature?: string; // 支付 0.2 SOL 费用的交易签名

  // 联合曲线相关
  mint?: string; // 如果是联合曲线代币，预先生成的mint地址
  isBondingCurve?: boolean; // 标记是否为联合曲线代币

  // 靓号地址配置
  enablePrettyAddress?: boolean;
  prettyPrefix?: string;
  prettySuffix?: string;
  caseSensitive?: boolean;
  threads?: number;

  // 社交链接
  website?: string;
  twitter?: string;
  telegram?: string;
  discord?: string;

  // 权限控制
  revokeUpdateAuthority?: boolean;
  revokeFreezeAuthority?: boolean;
  revokeMintAuthority?: boolean;
}

export interface UpdateTokenDto {
  name?: string;
  symbol?: string;
  description?: string;
  image?: string;
  price?: number;
  marketCap?: number;
  holders?: number;
}

// Transaction Types
export interface Transaction {
  id: string;
  signature: string;
  from: string;
  to: string;
  amount: number;
  type: 'BUY' | 'SELL' | 'CREATE' | 'TRANSFER';
  tokenMint?: string;
  blockTime: string;
  slot: string;
  fee: number;
  status: string;
  metadata?: any;
  createdAt: string;
}

// Price History Types
export interface PriceHistory {
  id: string;
  tokenMint: string;
  price: number;
  volume: number;
  marketCap: number;
  timestamp: string;
}

// User Types
export interface User {
  id: string;
  publicKey: string;
  username?: string;
  email?: string;
  avatar?: string;
  isActive: boolean;
  lastLoginAt?: string;
  createdAt: string;
  updatedAt: string;
}

// Health Check Types
export interface HealthStatus {
  status: 'ok' | 'partial' | 'not ready' | 'alive';
  timestamp: string;
  uptime?: number;
  version?: string;
  responseTime?: string;
  checks?: {
    database: boolean;
    helius: boolean;
    websocket: boolean;
  };
  websocket?: {
    onlineUsers: number;
  };
  memory?: any;
  reason?: string;
}

// Query Parameters
export interface TokensQuery {
  page?: number;
  limit?: number;
  orderBy?: 'createdAt' | 'marketCap' | 'price' | 'holders';
  order?: 'asc' | 'desc';
  search?: string;
}

export interface SearchQuery {
  q: string;
  limit?: number;
}

// WebSocket Events
export interface WebSocketEvents {
  // Client -> Server
  authenticate: { publicKey: string };
  subscribe_token: { mint: string };
  unsubscribe_token: { mint: string };
  subscribe_address: { address: string };
  
  // Server -> Client
  connected: { message: string; timestamp: string };
  authenticated: { publicKey: string; timestamp: string };
  subscribed: { type: 'token' | 'address'; mint?: string; address?: string; timestamp: string };
  unsubscribed: { type: 'token' | 'address'; mint?: string; address?: string; timestamp: string };
  token_price_update: { mint: string; price: number; marketCap: number; timestamp: string };
  token_transaction: { transaction: Transaction; timestamp: string };
  new_token: { token: Token; timestamp: string };
  new_transaction: { transaction: Transaction; timestamp: string };
  account_changed: { address: string; accountInfo: any; timestamp: string };
  error: { message: string };
}
